package fr.insta.reverse.uml.bean;

import static javax.persistence.GenerationType.IDENTITY;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

@Entity
@Table(name = "projet",
		catalog = "reverseUml",
		uniqueConstraints = @UniqueConstraint(columnNames = { "prj_lib", "prj_prop" }))
public class Projet implements java.io.Serializable
{

	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "prj_id", unique = true, nullable = false)
	private int id;

	@Column(name = "prj_lib", length = 100)
	private String lib;

	@Column(name = "prj_img", length = 100)
	private String img;

	@Column(name = "prj_img_uniq_key", length = 40)
	private String imgHash;

	@Column(name = "prj_svn", length = 100)
	private String svn;

	@ManyToOne
	@JoinColumn(name = "prj_prop")
	private User prop;

	@ManyToOne
	@JoinColumn(name = "prj_visibilite")
	private Visibilite visibilite;

	public Projet()
	{
	}

	public Projet(String lib, User prop)
	{
		this.lib = lib;
		this.prop = prop;
	}

	public Projet(String lib, String img, String svn, User prop, Visibilite visibilite)
	{
		this.lib = lib;
		this.img = img;
		this.svn = svn;
		this.prop = prop;
		this.visibilite = visibilite;
	}

	public Projet(String lib, String img, String imgHash, String svn, User prop, Visibilite visibilite)
	{
		this.lib = lib;
		this.img = img;
		this.imgHash = imgHash;
		this.svn = svn;
		this.prop = prop;
		this.visibilite = visibilite;
	}

	public int getId()
	{
		return id;
	}

	public void setId(int id)
	{
		this.id = id;
	}

	public String getLib()
	{
		return lib;
	}

	public void setLib(String lib)
	{
		this.lib = lib;
	}

	public String getImg()
	{
		return img;
	}

	public void setImg(String img)
	{
		this.img = img;
	}

	public String getSvn()
	{
		return svn;
	}

	public void setSvn(String svn)
	{
		this.svn = svn;
	}

	public User getProp()
	{
		return prop;
	}

	public void setProp(User prop)
	{
		this.prop = prop;
	}

	public Visibilite getVisibilite()
	{
		return visibilite;
	}

	public void setVisibilite(Visibilite visibilite)
	{
		this.visibilite = visibilite;
	}

	public String getImgHash()
	{
		return imgHash;
	}

	public void setImgHash(String _imgHash)
	{
		imgHash = _imgHash;
	}

	@Override
	public String toString()
	{
		return id + ", " + lib + ", " + img + ", " + svn + ", " + prop.getPrenom() + " " + prop.getNom() + ", " + visibilite.getLib();
	}
}
